//
//  SelectTyreViewController.m
//  BigTyre
//
//  Created by 田涛 on 2017/3/15.
//  Copyright © 2017年 Lemon. All rights reserved.
//

#import "SelectTyreViewController.h"
#import "XuanTaiData.h"
#import "SelectTyreModel.h"
#import "SelectMyTableViewCell.h"
#import <SDAutoLayout.h>

@interface SelectTyreViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    NSMutableArray*arrDada;
}
@property(nonatomic, strong)UITableView*tableView;

@end

@implementation SelectTyreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //通知传值
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(getCZ:) name:@"suo" object:nil];
    [[XuanTaiData shardData]getUrlRequest];
    [self getTableView];
    
}

//通知传值
-(void)getCZ:(NSNotification*)notificaion{
    arrDada=notificaion.object;
    NSLog(@"--------+++%@",arrDada);
    [_tableView reloadData];
}
-(void)getTableView{
    _tableView=[[UITableView alloc] initWithFrame:self.view.frame];
    _tableView.dataSource=self;
    _tableView.delegate=self;
    [self.view addSubview:_tableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return arrDada.count;
}

-(SelectMyTableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString*str=@"biao";
    SelectMyTableViewCell*cell=[tableView dequeueReusableCellWithIdentifier:str];
    if (!cell) {
        cell=[[SelectMyTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:str];
    }
    
    cell.model=arrDada[indexPath.row];
    
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    SelectTyreModel *model=arrDada[indexPath.row];
    
    
    return [tableView cellHeightForIndexPath:indexPath model:model keyPath:@"model" cellClass:[SelectMyTableViewCell class] contentViewWidth:[UIScreen mainScreen].bounds.size.width];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
